<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
    <style>
		.cs1{ color: green; }
		.cs2{ color: red;}
		
		.ct1{ color: green; }
		.ct2{ color: blue;}
		.ct3{ color:black;}
		.ct4{ color#C0F;}
		.ct5{ color#360;}
	</style>
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container">
    <form enctype="multipart/form-data" method="post" id="frm">
    	<input type="hidden" id="HasCashPassword" value="{$HasCashPassword}" />
    	<input type="hidden" name="p" id="NowPage" value="{$NowPage}" />
        <div class="table">          
            <div class="toolbars">
                <li class="toolbar"><a id="btnSaveAll" href="{$Url}recharge" title="我要在线充值" target="_self">我要在线充值</a></li>
                <li class="toolbar"><a id="btnSaveAll" onclick="setPwd()" title="设置提现密码" target="_self">设置提现密码</a></li>
                <li class="toolbar"><a id="btnEdit" onclick="withdraw()" >提现</a></li>
                <li class="toolbar toolbarform">
                    <label>类型</label>
                    <select name="CashType" id="CashType">
                        <option value="-1" selected="selected">全部</option>
                        <cashtypelist id="ct">
                        	<option value="{$ct.CashTypeID}">{$ct.CashTypeName}</option>
                        </cashtypelist>
                    </select>
                    <input id="btnSeek" class="btnToolbarForm" type="submit" value="查询" onclick="Search()">
                </li>
            </div>
            <table class="datatable" id="datatable">
                <tr>
                    <th width="45px"  nowrap="nowrap">ID</th>
                    <th  width="100px">金额</th>
                    <th  width="90px">类型</th>
                    <th width="80px" >状态</th>
                    
                    <th width="120px" >支付方式</th>
                    <th width="135px" >操作时间</th>
                    <th>备注</th>
                    <th width="75px">操作</th>
                </tr>  
                <notempty name="Data">
                    <volist name="Data" id="d">
                        <tr>
                            <td>{$d.CashID}</td>
                            <td>
                                <gt name="d.CashQuantity" value="0">
                                    <span class="ct{$d.CashType}">+{$d.CashQuantity}</span>
                                <else/>
                                    <span class="ct{$d.CashType}">{$d.CashQuantity}</span>
                                </gt>
                            </td>
                            <td><span class="ct{$d.CashType}">{$d.CashTypeName}</span></td>
                            <td>
                                <switch name="d.CashType">
                                    <case value="1">
                                        <eq name="d.CashStatus" value="1"><span class="cs1">已支付</span><else/><span class="cs2">未支付</span></eq>
                                    </case>
                                    <case value="4" comment="提现">
                                        <eq name="d.CashStatus" value="1"><span class="cs1">已付款</span><else/><span class="cs2">待付款</span></eq>
                                    </case>
                                    <default/>
                                        <eq name="d.CashStatus" value="1"><span class="cs1">完成</span><else/><span class="cs2">取消</span></eq>
                                </switch>
                            </td>
                            <td>{$d.PayName}</td>
                            <td>{$d.CashTime|strtotime|yd_friend_date}</td>
                            <td style="text-align:left;">
                                <eq name="d.CashType" value="4">
                                    <span style="margin-right:8px;"><b>收款银行：</b>{$d.BankName}</span>
                                    <span style="margin-right:8px;"><b>收款账号：</b>{$d.BankAccount}</span>
                                    <span><b>开户人姓名：</b>{$d.OwnerName}</span>
                                <else/>
                                 {$d.CashRemark}
                                </eq>
                            </td>
                            <td class="operator">
                                <eq name="d.CashStatus" value="2">
                                    <a style="float:left" onclick="del({$d.CashID})" class="btnDel">删除</a>
                                </eq>
                            </td>
                        </tr>
                    </volist>
                <else/>
                    <tr><td colspan="8"  id="NoData">{$Think.lang.NoDataTip}</td></tr>
                </notempty>
                <tr class="stat">
                    <td>总计</td>
                    <td><span style="color:red;">{$Total}</span></td>
                    <td colspan="6" style="text-align:left;padding-left:8px;">
                        我的充值总金额：<span style="color:red; margin-right:20px;">{$TotalQuantity}</span>
                        我的可用资金：<span style="color:red;">{$AvailableQuantity}</span>
                    </td>
                </tr>                       
            </table>
            <div class="tfoot"><div class="page">{$Page}</div></div>
        </div>
    </form>
</div>
</body>
</html>

<div class="dialog" id="dlgPwd" title="设置提现密码">
    <table class="dlgtable">
    		<eq name="HasCashPassword" value="1">
                <tr>
                    <th>原密码</th>
                    <td><input type="password" class="textinput" style="width:180px;" name="pwd1" id="pwd1" value="" /></td>
                </tr>
            </eq>
            <tr>
                <th>新密码</th>
                <td><input type="password" class="textinput" style="width:180px;"  name="pwd2" id="pwd2" value="" /></td>
            </tr>
            <tr>
                <th nowrap="nowrap">新密码确认</th>
                <td><input type="password" class="textinput" style="width:180px;"  name="pwd3" id="pwd3" value="" /></td>
            </tr>
    </table>
</div>
<script>
//提现
function withdraw(){
	var hasCashPassword = $("#HasCashPassword").val();
	if(hasCashPassword==0){
		ErrorBox("请先设置提现密码！");
		return false;
	}
	
	var CanWithdraw = parseInt("{$CanWithdraw}");
	if(CanWithdraw==0){
		var msg = "<span style='color:#333;'>";
		msg += "满<span style='color:red; padding:0 3px;'>{$WithdrawThreshold}</span>才能提现！";
		msg += "当前可用资金：<span style='color:red;'>{$AvailableQuantity}</span>";
		msg += "</span>";
		ErrorBox(msg);
		return false;
	}
	
	location.href="{$Url}withdraw";	

}

//设置提现密码
function setPwd(){
	$("#pwd1").val("");
	$("#pwd2").val("");
	$("#pwd3").val("");
	var dlg = $.dialog({
		title: $("#dlgPwd").attr("title"),
		id: 'dialog',
		lock: true,
		padding: 5,
		content: document.getElementById('dlgPwd'),
		ok: function () {
			LoadBox();
			var url = "{$Url}setPwd";
			var params = {
				pwd1 : $("#pwd1").val(),	
				pwd2 : $("#pwd2").val(),	
				pwd3 : $("#pwd3").val()
			}
			$.post(url, params, function(data){
					CloseLoadBox();
					if(data.status == 1){
						$("#HasCashPassword").val(1);
						SucceedBox(data.info);
						dlg.close();
					}else{
						ErrorBox(data.info);
						return false;
					}
			},"json");
			return false;
		},
		okValue: '保存',
		cancelValue: '关闭',
		cancel: function () {
			
		}
	});	
}

//检索
function Search(){
	$('#frm').attr("action", "{$Url}index");
	$('#frm').submit();
	return true;
}

//删除
function del(id){
	$.confirm("{$Think.lang.DeleteTip}", function () {
		var url = "{$Url}del?id="+id+"&p={$NowPage}&CashType={$CashType}";
		location.href = url;
	}, function () {
		return true;
	});
}

function pageInit(){
	$("#CashType").val( "{$CashType}");
}

$(document).ready(function(){
	pageInit();
});
</script>